﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VISS.API.Users {

    /// <summary>
    /// This interface is used for VISS.VN
    /// Used this interface to implement operations on UserMessage table
    /// </summary>
    public interface IUserMessage {

        /// <summary>
        /// Insert a new conversation between 2 users
        /// </summary>
        /// <param name="item">The UserMessageEnt item.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool InsertConversation(UserMessageEnt item);

        /// <summary>
        /// Insert a new message into a conversation between 2 users
        /// </summary>
        /// <param name="item">The UserMessageEnt item.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool InsertMessage(UserMessageEnt item);

        /// <summary>
        /// Set read for all messages of a conversation
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="conversationID">The conversation ID.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool SetRead(string userKey, long conversationID);

        /// <summary>
        /// Delete a message from sender
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="messageID">The message ID.</param>
        /// <returns></returns>
        bool SenderDeleteMessage(string userKey, long messageID);
        /// <summary>
        /// Delete a message from receiver
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="messageID">The message ID.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool ReceiverDeleteMessage(string userKey, long messageID);
        /// <summary>
        /// Delete a conversation from sender/receiver
        /// </summary>
        /// <param name="userKey"></param>
        /// <param name="conversationID"></param>
        /// <returns>Return true if success, otherwise return false</returns>
        bool DeleteConversation(string userKey, long conversationID);

        /// <summary>
        /// Get first message of a conversation
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="conversationID">The conversation ID.</param>
        /// <returns>
        /// Return UserMessageEnt if exists, otherwise return null
        /// </returns>
        UserMessageEnt GetConversation(string userKey, long conversationID);
        /// <summary>
        /// Get all messages of a conversation
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="conversationID">The conversation ID.</param>
        /// <returns>
        /// Return list of UserMessageEnt if exists, otherwise return empty list
        /// </returns>
        List<UserMessageEnt> GetConversationMessages(string userKey, long conversationID);
        /// <summary>
        /// Get latest messages of each conversation with paging
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="page">The page number.</param>
        /// <param name="recordPerPage">The record per page.</param>
        /// <param name="totalRecord">The total record.</param>
        /// <returns>
        /// Return list of UserMessageEnt if exists, otherwise return empty list
        /// </returns>
        List<UserMessageEnt> GetAllConversationWithPaging(string userKey, int page, int recordPerPage, out int totalRecord);
        /// <summary>
        /// get latest unread message of each conversation with paging
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="page">The page number.</param>
        /// <param name="recordPerPage">The record per page.</param>
        /// <param name="totalRecord">The total record.</param>
        /// <returns>
        /// Return list of UserMessageEnt if exists, otherwise return empty list
        /// </returns>
        List<UserMessageEnt> GetUnReadConversationWithPaging(string userKey, int page, int recordPerPage, out int totalRecord);
        /// <summary>
        /// Count unread messages of a user
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <returns>Return count number of messages</returns>
        int GetUnReadMessagesCount(string userKey);
        /// <summary>
        /// Check if user 1 can still send messages to user 2
        /// </summary>
        /// <param name="userKey1">The user key1.</param>
        /// <param name="userKey2">The user key2.</param>
        /// <returns>true if can, otherwise false is can not</returns>
        bool CheckUser1CanSendMessageToUser2(string userKey1, string userKey2);
    }
}
